/**
 * Created by LuBangTao on 2017/3/30.
 */
var dude = function (scene) {
    BABYLON.SceneLoader.ImportMesh("", "model/", "Dude.babylon", scene, function (newMeshes) {
        var material =  new  BABYLON.StandardMaterial("material",scene);
        material.wireframe = true;
        material.backFaceCulling = false;
        var mesh = newMeshes[0];
        mesh.isVisible = false;
        for(var j = 0;j<newMeshes[0].getChildren().length;j++){
            var positions = newMeshes[0].getChildren()[j].getVerticesData(BABYLON.VertexBuffer.PositionKind);
            var indices = newMeshes[0].getChildren()[j].getIndices();
            for(var i=0;i<indices.length;i+=3){
                var customMesh = new BABYLON.Mesh("custom"+i, scene);
                var positions1 = [positions[indices[i]*3],positions[indices[i]*3+1],positions[indices[i]*3+2],positions[indices[i+1]*3],positions[indices[i+1]*3+1],positions[indices[i+1]*3+2],positions[indices[i+2]*3],positions[indices[i+2]*3+1],positions[indices[i+2]*3+2]];
                var indices1 = [0, 1, 2];
                var normals = [];
                BABYLON.VertexData.ComputeNormals(positions1, indices1, normals);
                var vertexData = new BABYLON.VertexData();
                vertexData.positions = positions1;
                vertexData.indices = indices1;
                vertexData.normals = normals;
                vertexData.applyToMesh(customMesh);
                customMesh.material  =material;
            }

        }
        console.log(scene.meshes.length)
    })
};